'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, DATE, STRING,UUID, ENUM  }  = Sequelize;
    await queryInterface.createTable('users',{
      id:{ type:INTEGER, primaryKey:true, unique: true, autoIncrement:true },
      uuid:{ type:UUID, defaultValue:Sequelize.UUIDV4 },
      nickname:{ type:STRING,allowNull:false },
      sex:{ type:ENUM, values:['male','female','unknown'] },
      tel:{ type:STRING(11), allowNull:false, unique: true, is:/^1(3|4|5|6|7|8|9)\d{9}$/, validate:{ notNull:{ msg:'请输入你的手机号' } } },
      avator:{ type:STRING },
      password:{ type:STRING, allowNull:false, validate:{ notNull:{ msg:'请输入你的密码' } } },
      username:{ type:STRING(50) }
    });
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('users');
  }
};
